package com.house.controller;


import com.house.common.Result;
import com.house.entity.Remark;
import com.house.service.RemarkService;
import com.house.util.ResultUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author asus
 * @since 2021-02-28
 */
@RestController
@RequestMapping("/remark")
public class RemarkController {

    @Resource
    private RemarkService remarkService;

    @GetMapping("/selectHouseReviewsByHouseId/{houseId}")
    public Result selectHouseReviewsByHouseId(@PathVariable("houseId") Integer houseId)
    {
        List<Remark> remarks = remarkService.selectRemarkByHouseId(houseId);
        return ResultUtil.success(203,remarks);
    }

    @PostMapping("/submitHouseRemark")
    public Result submitHouseRemark(@RequestBody Remark remark)
    {
        Integer state = remarkService.submitRemark(remark);

        return ResultUtil.success(202, state);
    }

    @PostMapping("/deleteRemark")
    public Result deleteRemark(@RequestParam("remarkId") Integer remarkId)
    {
        Integer state = remarkService.deleteRemark(remarkId);
        return ResultUtil.success(204, state);
    }
}
